import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 智慧祝福
 **/
export default class QS_IntelligenceBless extends AbilityBase {
    static instance: QS_IntelligenceBless;
    buffType: AppBuffType = {
        id: 'buff_QS_IntelligenceBless',
        art: this.art,
        name: this.abilityName,
        ubertip: '你的智力和精神得到了加强',
        dur: 20,
        targetArt: 'Abilities\\Spells\\Human\\ControlMagic\\ControlMagicTarget.mdl',
        targetAttach: 'overhead',
        attribute: {},
    };
    constructor(id: string) {
        super(id);
        QS_IntelligenceBless.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        let lv = this.getAbilityLevel(source);
        // let buff = BuffUtil.addBuff(target, this.buffType.id, source);
        let val = 5 * lv + UnitCommon.取法强(source) * (0.65 + 0.25 * lv);
        // buff.attribute = {
        //     自定义智力: val,
        //     intelligence: val,
        // };
        BuffCommon.addBuff({
            target,
            caster: source,
            buffTypeId: this.buffType.id,
            ablityId: this.id,
            attribute: {
                自定义智力: val,
                intelligence: val,
            },
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
